package com.billjc.hrm.action;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.billjc.hrm.base.IbatisSessionFactory;
import com.billjc.hrm.model.EducationBackground;
import com.billjc.hrm.model.Employee;
import com.billjc.hrm.model.ItSkill;
import com.billjc.hrm.model.LanguageSkill;
import com.billjc.hrm.model.TrainingBackground;
import com.opensymphony.xwork2.ActionSupport;
import static com.opensymphony.xwork2.Action.*;

@ParentPackage("json-default")
@Results( { @Result(name = SUCCESS, type = "json"),
		@Result(name = INPUT, type="redirect",location = "") })
public class EmployeeInfoAction extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 3127935026320434476L;
	private Integer id = null;
	private Employee employee = null;
	private List<EducationBackground> educationList = null;
	private List<ItSkill> itSkilList = null;
	private List<TrainingBackground> trainingBg = null;
	private List<LanguageSkill> languageList = null;
	private SqlSessionFactory sessionfactory = IbatisSessionFactory
			.getSqlSessionFactory();

	public String list() throws Exception {
		SqlSession session = sessionfactory.openSession();
		employee = (Employee) session.selectOne("employee.employeeInfoOne", id);
		educationList = session.selectList(
				"educationbackground.employeeEducationBackgroundDetail", id);
		itSkilList = session.selectList("itskill.employeeItSkilDetail", id);
		trainingBg = session.selectList(
				"trainingbackground.employeeTrainingDetail", id);
		setLanguageList(session.selectList(
				"languageskill.employeeLanguageSkillDetail", id));
		return SUCCESS;
	}

	public Employee getEmployee() {
		return employee;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public void setEducationList(List<EducationBackground> educationList) {
		this.educationList = educationList;
	}

	public List<EducationBackground> getEducationList() {
		return educationList;
	}

	public void setItSkilList(List<ItSkill> itSkilList) {
		this.itSkilList = itSkilList;
	}

	public List<ItSkill> getItSkilList() {
		return itSkilList;
	}

	public void setTrainingBg(List<TrainingBackground> trainingBg) {
		this.trainingBg = trainingBg;
	}

	public List<TrainingBackground> getTrainingBg() {
		return trainingBg;
	}

	public void setLanguageList(List<LanguageSkill> languageList) {
		this.languageList = languageList;
	}

	public List<LanguageSkill> getLanguageList() {
		return languageList;
	}

}
